home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / comm.swg / 0021_Get Device Function.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-23  |  1.7 KB  |  50 lines

  1. {
  2. ===========================================================================
  3.  BBS: Canada Remote Systems
  4. Date: 08-16-93 (19:59)             Number: 34567
  5. From: ERIC GIVLER                  Refer#: NONE
  6.   To: ALL                           Recvd: NO
  7. Subj: PROBLEM                        Conf: (1221) F-PASCAL
  8. ---------------------------------------------------------------------------
  9. When I start up the BBS and it has the wrong port# (ie Com1 instead of 2),
  10. the machine will lockup trying to write to the modem.  If the port is
  11. correct, there are NO problems as long as the modem is on.  Is there a
  12. graceful way of detecting this and remedying it - ie.  Even an abort
  13. to DOS with an errorlevel would be nicer than a LOCKUP!  The following
  14. idea is what I've tried.  It DOES appear to work!
  15. }
  16. USES CRT,DOS;
  17.  
  18. function is_device_ready( devicename:string) : boolean;
  19. var r      : registers; handle : word; ready  : byte;
  20. begin
  21.      ready := 0;
  22.      r.ds := seg(devicename);
  23.      r.dx := ofs(devicename[1]);
  24.      r.ax := $3d01;
  25.      msdos(r);
  26.      if (r.flags and fCarry) <> fCarry then
  27.      begin
  28.          handle := r.ax;
  29.          ready  := 1;
  30.          r.ax := $4407;
  31.          r.bx := handle;
  32.          msdos(r);
  33.          ready := ready and r.AL;
  34.          r.ah := $3e;
  35.          r.bx := handle;
  36.          msdos(r);
  37.      end;
  38.      is_device_ready := ( ready = 1 );
  39. end; { is_device_ready }
  40.  
  41. begin
  42.    ClrScr;
  43.    writeln('COM2 is ready ..', is_device_ready('COM2'+#00) );
  44.    writeln('COM1 is ready ..', is_device_ready('COM1'+#00) );
  45.    writeln('LPT1 is ready ..', is_device_ready('PRN' + #00) );
  46. end.
  47.  
  48. --- msgedsq 2.1
  49.  * Origin: Noname Consultants (717)561-8033 (1:270/101.15)
  50.